# Project name
PROJNAME = amber_haruhi

DEFINES := -D TEXT_MODE
INCLUDE_PATH := -I./
COMPILE_OPTIONS := $(DEFINES) -Wall -O2
LIBS = -lm
LDFLAGS = $(LINK_OPTIONS) $(LIB_PATH)

CC = gcc
OBJDUMP = objdump
OBJCOPY = objcopy
STRIP = strip
LD = ld
AR = ar
AS = as
MKDIR = /bin/mkdir
RM = rm -f

# All .o
# ===========================================
SRC_PREFIX_LIST = base_card board card_img dqueue main my_card_dqueue account ah_protocol GeneralHashFunctions mempool
OBJS := $(foreach item,$(SRC_PREFIX_LIST),$(item).o)

amber_haruhi: $(OBJS)
	$(CC) -o $(PROJNAME) $(OBJS) $(LIBS)
base_card.o: base_card.c base_card.h
	$(CC) -c base_card.c $(COMPILE_OPTIONS)
board.o: board.c board.h
	$(CC) -c board.c $(COMPILE_OPTIONS)
card_img.o: card_img.c card_img.h
	$(CC) -c card_img.c $(COMPILE_OPTIONS)
dqueue.o: dqueue.c dqueue.h
	$(CC) -c dqueue.c $(COMPILE_OPTIONS)
GeneralHashFunctions.o: GeneralHashFunctions.c GeneralHashFunctions.h
	$(CC) -c GeneralHashFunctions.c $(COMPILE_OPTIONS)
my_card_dqueue.o: my_card_dqueue.c my_card_dqueue.h base_card.h
	$(CC) -c my_card_dqueue.c $(COMPILE_OPTIONS)
account.o: account.c account.h mempool.h
	$(CC) -c account.c $(COMPILE_OPTIONS)
ah_protocol.o: ah_protocol.c ah_protocol.h
	$(CC) -c ah_protocol.c $(COMPILE_OPTIONS)
main.o: main.c card_img.h base_card.h board.h my_card_dqueue.h account.h mempool.h
	$(CC) -c main.c $(COMPILE_OPTIONS)
mempool.o: mempool.c mempool.h dqueue.h
	$(CC) -c mempool.c $(COMPILE_OPTIONS) -std=c99
clean:
	$(RM) *.o *.out
